﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#pragma execution_character_set("utf-8")
#include <QtCore>
#include <QOpenGLWidget>
#include <osgViewer/Viewer>
#include <osg/Drawable>
#include <osg/ShapeDrawable>
#include <osgGA/TrackballManipulator>
#include <osg/Material>
#include <QMouseEvent>
#include "qtosgWidget.h"
#include <osg/Material>
#include <btBulletCollisionCommon.h>
#include <btBulletDynamicsCommon.h>
#include <BulletDynamics/Vehicle/btRaycastVehicle.h>
#include <osgViewer/ViewerEventHandlers>
#include <osg/Texture2D>

#include "followupdater.h"
#include"btosgvehicle.h"
#include <osg/Depth>

#include "algothread.h"
#include "gameworld.h"
#include "purepursuit.h"


#include <QTimer>
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void initStyle();

    void update();
    void realTimeUpdate();
    void CreateSubwid();
    //规划路径成功调用的函数
    void InfoBox();
    void InfoBoxFail();

    //键盘控制
public slots:
    void SlotStartThread();
    //通过输入路径，让其行走
    void changePurepursuit();
    //计算轨迹
    void CalTraj();


public:
    btosgWorld *myWorld;
//    btosgVehicle *myVehicle;
    btosgMyCar *myVehicle;
    QTimer *timer;
    QTimer *timer2;
    QTimer *timer3;

    QElapsedTimer * realTimer;
    QElapsedTimer * TimergetSpan;

    osgViewer::Viewer *viewer;
    QtOSGWidget *osg_widget;

    //副视角
    QtOSGWidget *osg_widget1;
    osgViewer::Viewer *viewer1;


    //线程
    AlgoThread* m_thread;
    std::thread threadOsg;


    float dt;
    float lastTime;
    purepursuit *ab;


private slots:
    void on_pushButton_planTraj_clicked();

    void on_pushButton_eliminateTraj_clicked();

    void on_pushButton_trajTrack_clicked();

    void on_pushButton_trajStop_clicked();

    void on_pushButton_mainView_clicked();

    void on_pushButton_subView_clicked();

    void on_pushButton_applyEngine_clicked();

    void on_pushButton_applyForce_clicked();

    void on_pushButton_applyWeight_clicked();

    void on_pushButton_posOrigin_clicked();

    void on_pushButton_posCrater_clicked();

    void on_action_manCtl_triggered();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H
